package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.ClientTarkingList;
import cn.wolfcode.crm.query.ClientTarkingListQuery;
import cn.wolfcode.crm.service.IClientTarkingListService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/clientTarkingList")
public class ClientTarkingListController {
    @Autowired
    private IClientTarkingListService clientTarkingListService;

    //客户计划视图
    @RequestMapping("/view")
    public String index() {

        return "client/clientTarkingList";
    }


    @RequestMapping("/selectAll")
    @ResponseBody
    public Object selectAll() {
        return clientTarkingListService.listAll();
    }

    @RequestMapping("/query")
    @ResponseBody
    public Object query(ClientTarkingListQuery qo) {
        PageResult query = clientTarkingListService.query(qo);
        return query;
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(ClientTarkingList entity) {
        try {
            clientTarkingListService.saveOrUpdate(entity);
        } catch (Exception ex) {
            ex.printStackTrace();
            return new JsonResult().mark(ex.getMessage());
        }
        return new JsonResult();
    }


    //删除客户计划
    @RequestMapping("delete")
    @ResponseBody
    public JsonResult delete(Long id) {
        clientTarkingListService.delete(id);
        return new JsonResult();
    }


}
